class Solution:
    def timeRequiredToBuy(self, tickets, k):
        time = 0
        while tickets[k] > 0:
            for i in range(len(tickets)):
                if tickets[i] > 0:
                    tickets[i] -= 1
                    time += 1
                if tickets[k] == 0:
                    return time
        return time
                
if __name__ == '__main__':
    tickets = [2,3,2]
    k = 2
    print(Solution().timeRequiredToBuy(tickets, k))